// Use ajax to get the top 10 swimmers of the chosen category.
function getTop10(group, gender, type, length) {
	// Get the ajax object.
	var xmlhttp = getAjaxObject();
	
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
			// Display the top 10 swimmers in a table.
			document.getElementById("top10Results").innerHTML = xmlhttp.responseText;
		}
	}
	
	var data = "group=" + group + "&gender=" + gender + "&type=" + type + "&length=" + length;
	// Send the data to the php script to get the top 10 swimmers
	xmlhttp.open("GET", "./ajax_top10/top10Results.php?" + data, true);
	xmlhttp.send(null);
}

// Create an ajax object and return it.
function getAjaxObject() {
	var xmlhttp = null;
	try {
		xmlhttp = new XMLHttpRequest();
	}
	catch(err) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(err) {
			alert("Error, your browser does not support AJAX");
		}
	}
	return xmlhttp;
}